package com.github.livebase.log;
/**
 * @ClassName ConsoleLog
 * @description:
 * @author: biao532
 * @create: 2024-02-02 14:23
 * @Version 1.0
 **/
public class ConsoleLogger implements Logger {
    private static final String TAG = "ConsoleLog";
    private static volatile Logger logger;
    public static Logger getLogger() {
        if (logger == null) {
            synchronized (ConsoleLogger.class) {
                if (null == logger) {
                    logger = new ConsoleLogger();
                }
            }
        }
        return logger;
    }
    private Formatter formatter;
    private ConsoleLogger() {
        this.formatter = LFormatter.getFormatter();
    }
    @Override
    public boolean isTrance() {
        return android.util.Log.isLoggable(TAG, android.util.Log.VERBOSE);
    }

    @Override
    public void trance(String tag, Throwable throwable, String format, Object... params) {
        android.util.Log.v(tag, formatter.format(throwable, format, params));
    }


    @Override
    public boolean isDebug() {
        return android.util.Log.isLoggable(TAG, android.util.Log.DEBUG);
    }

    @Override
    public void debug(String tag, Throwable throwable, String format, Object... params) {
        android.util.Log.d(tag, formatter.format(throwable, format, params));
    }


    @Override
    public boolean isInfo() {
        return android.util.Log.isLoggable(TAG, android.util.Log.INFO);
    }

    @Override
    public void info(String tag, Throwable throwable, String format, Object... params) {
        android.util.Log.i(tag, formatter.format(throwable, format, params));
    }

    @Override
    public boolean isWarm() {
        return android.util.Log.isLoggable(TAG, android.util.Log.WARN);
    }

    @Override
    public void warn(String tag, Throwable throwable, String format, Object... params) {
        android.util.Log.w(tag, formatter.format(throwable, format, params));
    }


    @Override
    public boolean isError() {
        return android.util.Log.isLoggable(TAG, android.util.Log.ERROR);
    }

    @Override
    public void error(String tag, Throwable throwable, String format, Object... params) {
        android.util.Log.e(tag, formatter.format(throwable, format, params));
    }
}
